package com.example.xuwsh.myBatisPlus.core.abstracts;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.AbstractLambdaWrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.example.xuwsh.myBatisPlus.core.interfaces.JuXiLambdaInterfaceWrapper;

import java.util.Collection;

/**
 * @Author: xuwsh
 * @Date: 2023/09/21/11:07
 * @Description:
 */
@Deprecated
public abstract class JuXiLambdaWrapper<Children, T> extends AbstractLambdaWrapper<T, JuXiLambdaWrapper<Children, T>> implements JuXiLambdaInterfaceWrapper<Children, T> {
    @Override
    public Children eqIfPresent(SFunction<T, ?> column, Object val) {
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) super.eq(column, val);
        }
        return (Children) this;
    }

    @Override
    public Children neIfPresent(SFunction<T, ?> column, Object val) {
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) super.ne(column, val);
        }
        return (Children) this;
    }

    @Override
    public Children gtIfPresent(SFunction<T, ?> column, Object val) {
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) super.gt(column, val);
        }
        return (Children) this;
    }

    @Override
    public Children geIfPresent(SFunction<T, ?> column, Object val) {
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) super.ge(column, val);
        }
        return (Children) this;
    }

    @Override
    public Children ltIfPresent(SFunction<T, ?> column, Object val) {
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) super.lt(column, val);
        }
        return (Children) this;
    }

    @Override
    public Children leIfPresent(SFunction<T, ?> column, Object val) {
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) super.le(column, val);
        }
        return (Children) this;
    }

    @Override
    public Children betweenIfPresent(SFunction<T, ?> column, Object val, Object val1) {
        if (ObjectUtil.isNotEmpty(val) && ObjectUtil.isNotEmpty(val1)) {
            return (Children) super.between(column, val, val1);
        }
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) ge(column, val);
        }
        if (ObjectUtil.isNotEmpty(val1)) {
            return (Children) le(column, val1);
        }
        return (Children) this;
    }

    @Override
    public Children notBetweenIfPresent(SFunction<T, ?> column, Object val, Object val1) {
        if (ObjectUtil.isNotEmpty(val) && ObjectUtil.isNotEmpty(val1)) {
            return (Children) super.notBetween(column, val, val1);
        }
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) lt(column, val);
        }
        if (ObjectUtil.isNotEmpty(val1)) {
            return (Children) gt(column, val1);
        }
        return (Children) this;
    }

    @Override
    public Children likeIfPresent(SFunction<T, ?> column, Object val) {
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) super.like(column, val);
        }
        return (Children) this;
    }

    @Override
    public Children noLikeIfPresent(SFunction<T, ?> column, Object val) {
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) super.notLike(column, val);
        }
        return (Children) this;
    }

    @Override
    public Children likeLeftIfPresent(SFunction<T, ?> column, Object val) {
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) super.likeLeft(column, val);
        }
        return (Children) this;
    }

    @Override
    public Children notLikeLeftIfPresent(SFunction<T, ?> column, Object val) {
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) super.notLikeLeft(column, val);
        }
        return (Children) this;
    }

    @Override
    public Children likeRightIfPresent(SFunction<T, ?> column, Object val) {
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) super.likeRight(column, val);
        }
        return (Children) this;
    }

    @Override
    public Children notLikeRightIfPresent(SFunction<T, ?> column, Object val) {
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) super.notLikeRight(column, val);
        }
        return (Children) this;
    }

    @Override
    public Children isNullIfPresent(SFunction<T, ?> column, Object val) {
        if (ObjectUtil.isEmpty(val)) {
            return (Children) super.isNull(column);
        }
        return (Children) this;
    }

    @Override
    public Children isNotNullIfPresent(SFunction<T, ?> column, Object val) {
        if (ObjectUtil.isNotEmpty(val)) {
            return (Children) super.isNotNull(column);
        }
        return (Children) this;
    }


    @Override
    public Children inListIfPresent(SFunction<T, ?> column, Collection<?> coll) {
        if (CollectionUtil.isNotEmpty(coll)) {
            return (Children) super.in(column, coll);
        }
        return (Children) this;
    }

    @Override
    public Children notInListIfPresent(SFunction<T, ?> column, Collection<?> coll) {
        if (CollectionUtil.isNotEmpty(coll)) {
            return (Children) super.notIn(column, coll);
        }
        return (Children) this;
    }

    @Override
    public Children inArrayIfPresent(SFunction<T, ?> column, Object... values) {
        if (ObjectUtil.isAllNotEmpty(values)) {
            return (Children) super.in(column, values);
        }
        return (Children) this;
    }

    @Override
    public Children notInArrayIfPresent(SFunction<T, ?> column, Object... values) {
        if (ObjectUtil.isAllNotEmpty(values)) {
            return (Children) super.notIn(column, values);
        }
        return (Children) this;
    }
}
